package mmc.networking;

import mmc.RemoteServer;
import mmc.server.RemoteClient;

@SuppressWarnings("serial")
public class Quit extends Message {

	public final QuitCause quitCause;
	
	public Quit(QuitCause cause){
		this.quitCause = cause;
	}
	
	@Override
	public void executeOnServer(RemoteClient context) {
		context.breakConnection();
		context.post(this);
	}
	
	@Override
	public void executeOnClient(RemoteServer context) {
		System.out.println("quit arrived with "+quitCause);
		context.closeSocket(quitCause);
	}

	public static enum QuitCause{
		CLIENT_SHUTDOWN, SERVER_SHUTDOWN, CONNECTION_BROKEN;
	} 
}
